package com.itzm;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcText {
    @Test
    public void testUpdate() throws Exception {
       //1.注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //2.获取数据连接
        String url = "jdbc:mysql://localhost:3306/web01";
        String username = "root";
        String password = "1234";
        Connection connection=DriverManager.getConnection(url,username,password);
        //3.获取执行sql语句的对象
        Statement statement=connection.createStatement();
        //4.执行sql语句
        int i =  statement.executeUpdate("update user set age='25' where id=1");
        System.out.println("sql执行完毕影响的记录为："+i);

        //6.释放资源
 statement.close();
 connection.close();
    }

}
